package com.day0913;

public class Text8 {
    /**
     *@description：
     *@author：
     *@date：
     *@param：
     */

        int[] numArray = {12,14,16,25,10};
        public static String myToString(int[] arrInt) {
            String resStr ="";
            //arrInt 转换成以下格式的字符串
            // "[99, 85, 82, 63, 63, 60]"
            for (int i = 0; i < arrInt.length; i++){
                if(i == arrInt.length - 1){
                    resStr = resStr + arrInt[i];
                }
                else {
                    resStr = resStr + arrInt[i] + ",";
                }
            }
            resStr = "[" + resStr + "]";
            return resStr;
        }




        public static int[]  myCopyOf(int[] arrInt,int length) {
            int[] resArray = new int[length];
//            if(length < arrInt.length){
//                for(int i = 0; i < length; i ++){
//                    resArray[i] = arrInt[i];
//                }
//            }
//            else if(length >= arrInt.length){
//                for(int i = 0; i < arrInt.length; i ++){
//                    resArray[i] = arrInt[i];
//                }
//            }
            int len = length;
            if(length >= arrInt.length){
                len = arrInt.length;
            }
            for(int i = 0; i < len; i ++){
                    resArray[i] = arrInt[i];
                }


            //传进来的数组arrInt 赋值新数组resArray
            //length 有可能是小于arrInt 数组长度。
            return resArray;
        }
    }
